/*
 * @Author: jiayu
 * @Date: 2022-09-19 10:11:51
 * @LastEditors: jiayu
 * @LastEditTime: 2022-09-23 17:50:49
 * @Description: 
 */
import axios from 'axios';

export const instance = axios.create({
  baseURL: window.base_url, //'http://dev.pano-v.cn'
  timeout: 1000,
  headers: {
    // 'http-authorization': window.token
  },
});

// 添加响应拦截器
instance.interceptors.response.use(function (response) {
  // 对响应数据做点什么
  if (response.data.code == '4001') {
    window.location.href = window.login_url
  }
  return response.data;
}, function (error) {
  // 对响应错误做点什么
  return Promise.reject(error);
});


/** 获取当前的用户 GET /api/currentUser */
export async function getDep(options?: { [key: string]: any }) {
  return instance('/index/Screen/getDep', {
    method: 'GET',
    ...(options || {}),
  });
}


/** 获取当前的用户 GET /api/currentUser */
export async function getCurrentUser(options?: { [key: string]: any }) {
  return instance('api/user/getUserInfo', {
    method: 'GET',
    ...(options || {}),
  });
}
